﻿namespace Services;

/// <summary>
/// 代理商
/// </summary>
[Authorize, ApiDescriptionSettings("代理商")]
public class ProxyTeamBuy : BaseServices
{
    private readonly ISqlSugarClient db;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="db"></param>
    public ProxyTeamBuy(ISqlSugarClient db)
    {
        this.db = db;
    }

    /// <summary>
    /// 获取拼团信息
    /// </summary>
    /// <param name="state"></param>
    /// <returns></returns>
    public async Task<object> Get(int state)
    {
        var data = await db.Queryable<Entity.TeamBuy>()

            .Where(x => x.StoreId == PROXYID)

            .WhereIF(state >= 0, x => x.State == (Entity.TeamBuyState)state)

            .Includes(x => x.Product)

            .OrderByDescending(x => x.Id)

            .ToPagedListAsync(PageNo, PageSize);

        return Ok(data);
    }
}
